package com.dc.business.datacollectbusiness.mapper;

import com.dc.business.datacollectbusiness.model.tbengPushCustomData;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface publicInstitutionMapper {

    // 根据collectid查询最新时间的采集器相关信息
    @Select("SELECT * FROM tbeng_push_custom_data " +
            "WHERE tf_collecter_product_code = #{tfCollecterProductCode} And channelno = '1'" +
            "ORDER BY upload_time DESC " +
            "LIMIT 1")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "uploadTime", column = "upload_time"),
            @Result(property = "tfSensorProductCode", column = "tf_sensor_product_code"),
            @Result(property = "tfBat", column = "tf_bat"),
            @Result(property = "tfCsq", column = "tf_csq"),
            @Result(property = "pv", column = "pv"),
            @Result(property = "tfCollecterProductCode", column = "tf_collecter_product_code"),
            @Result(property = "channelno", column = "channelno"),
            @Result(property = "status", column = "status"),
            @Result(property = "pvVer", column = "pv_ver")
    })
    public tbengPushCustomData findLatestByTfCollecterProductCodeA(@Param("tfCollecterProductCode") String tfCollecterProductCode);


    @Select("SELECT * FROM tbeng_push_custom_data " +
            "WHERE tf_collecter_product_code = #{tfCollecterProductCode} And channelno = '2'" +
            "ORDER BY upload_time DESC " +
            "LIMIT 1")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "uploadTime", column = "upload_time"),
            @Result(property = "tfSensorProductCode", column = "tf_sensor_product_code"),
            @Result(property = "tfBat", column = "tf_bat"),
            @Result(property = "tfCsq", column = "tf_csq"),
            @Result(property = "pv", column = "pv"),
            @Result(property = "tfCollecterProductCode", column = "tf_collecter_product_code"),
            @Result(property = "channelno", column = "channelno"),
            @Result(property = "status", column = "status"),
            @Result(property = "pvVer", column = "pv_ver")
    })
    public tbengPushCustomData findLatestByTfCollecterProductCodeB(@Param("tfCollecterProductCode") String tfCollecterProductCode);

}
